package com.c.ctgproject.ui.review.part

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.c.ctgproject.base.BaseViewModel
import com.c.ctgproject.http.ApiMethods
import com.c.ctgproject.utils.awaitSync
import com.c.ctgproject.utils.handlerBody
import com.c.ctgproject.utils.launch
import com.c.ctgproject.utils.userToken

class PartOrderDetailViewModel : BaseViewModel() {



    private val mConfirmOrder = MutableLiveData<String>()
    val confirmOrder: LiveData<String> get() = mConfirmOrder


    //修改审核意见
    fun orderConfirm(msg: String, isPass: Int, orderId: Int){
        launch({
            mConfirmOrder.value = ApiMethods.getApiService().changePartStatus(
                userToken, handlerBody("isPass" to isPass, "auditOpinion" to msg, "partsSalesOrderId" to orderId)
            ).awaitSync()
        }, {
            mError.value = it.message.toString()
        })
    }


}